package com.sf.bigscreen.controller;

import com.sf.bigscreen.entity.Result;
import com.sf.bigscreen.service.IDayWaService;
import com.sf.bigscreen.service.IDayWeatherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: bi xuan
 * @Date: 2021/7/9 8:40
 * @Description:
 **/
@Api(tags="关于水表信息的参数接口")
@RestController
@RequestMapping("/dayWa")
public class DayWaController {
    @Autowired
    private IDayWaService dayWaterService;
    @ApiOperation("同步一段时间的全校水费数据")
    @GetMapping("/updateDayAmAll")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dateStart", value = "起始时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-10", required = true),
            @ApiImplicitParam(name = "dateEnd", value = "结束时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-12", required = true),
    })
    public Result updateDayAmAllInfo(@RequestParam("dateStart") String dateStart, @RequestParam("dateEnd") String dateEnd){
        dayWaterService.addOrUpdateDayWaAllInfoRangeTime(dateStart,dateEnd);
        return Result.buildSuccessMessage("同步一段时间的全校水费数据成功");
    }

    @ApiOperation("同步一段时间的区域水费数据")
    @GetMapping("/updateDayWaArea")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "areaId", value = "区域id", dataType = "int", paramType = "query", example = "1", required = true),
            @ApiImplicitParam(name = "dateStart", value = "起始时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-10", required = true),
            @ApiImplicitParam(name = "dateEnd", value = "结束时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-12", required = true),
    })
    public Result updateDayWaAreaInfo(@RequestParam("areaId") Integer areaId,@RequestParam("dateStart") String dateStart,@RequestParam("dateEnd") String dateEnd){
        dayWaterService.addOrUpdateDayWaAreaInfoRangeTime(areaId, dateStart, dateEnd);
        return Result.buildSuccessData(1);
    }

    @ApiOperation("同步一段时间的建筑水费数据")
    @GetMapping("/updateDayWaArc")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "arcId", value = "建筑id", dataType = "int", paramType = "query", example = "1", required = true),
            @ApiImplicitParam(name = "dateStart", value = "起始时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-10", required = true),
            @ApiImplicitParam(name = "dateEnd", value = "结束时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-12", required = true),
    })
    public Result updateDayWaArcInfo(@RequestParam("arcId") Integer arcId,@RequestParam("dateStart") String dateStart,@RequestParam("dateEnd") String dateEnd){
        dayWaterService.addOrUpdateDayWaArcInfoRangeTime(arcId, dateStart, dateEnd);
        return Result.buildSuccessMessage("同步一段时间的建筑水费数据");
    }

    @ApiOperation("同步一段时间的部门水费数据")
    @GetMapping("/updateDayWaPart")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "departmentId", value = "部门id", dataType = "int", paramType = "query", example = "1", required = true),
            @ApiImplicitParam(name = "dateStart", value = "起始时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-10", required = true),
            @ApiImplicitParam(name = "dateEnd", value = "结束时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-12", required = true),
    })
    public Result updateDayWaPartInfo(@RequestParam("departmentId") Integer departmentId,@RequestParam("dateStart") String dateStart,@RequestParam("dateEnd") String dateEnd){
        dayWaterService.addOrUpdateDayWaDepartmentInfoRangeTime(departmentId, dateStart, dateEnd);
        return Result.buildSuccessMessage("同步一段时间的部门水费数据");
    }

    @ApiOperation("同步一段时间的单只水表水费数据")
    @GetMapping("/updateDayWaMeter")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "meterId", value = "电表id", dataType = "int", paramType = "query", example = "1", required = true),
            @ApiImplicitParam(name = "dateStart", value = "起始时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-10", required = true),
            @ApiImplicitParam(name = "dateEnd", value = "结束时间(时间字符串格式为yyyy-mm-dd)", dataType = "string", paramType = "query", example = "2021-07-12", required = true),
    })
    public Result updateDayWaMeterInfo(@RequestParam("meterId") Integer meterId,@RequestParam("dateStart") String dateStart,@RequestParam("dateEnd") String dateEnd){
        dayWaterService.addOrUpdateDayWaInfoRangeTime(meterId, dateStart, dateEnd);
        return Result.buildSuccessMessage("同步一段时间的单只水表水费数据");
    }
}
